package cn.yoyo.controller.adm;

import cn.yoyo.service.LargefileService;
import cn.yoyo.service.UserService;
import cn.yoyo.tools.RespJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Controller
@RequestMapping("/api/adm/user")
public class AdmUserController {
    @Autowired
    UserService userService;
    @Autowired
    LargefileService largefileService;

    @RequestMapping("/go2UserList")
    public String go2UserList(){
        return "user/userList";
    }

    @RequestMapping("/go2Info")
    public String go2Info(){
        return "user/info";
    }

    @RequestMapping("/findAll")
    @ResponseBody
    public Map<String,Object> findAll(){
        return RespJson.pack(200,"",userService.findAll());
    }

    @RequestMapping("/block/{id}/{block}")
    @ResponseBody
    public Map<String,Object> block(@PathVariable("id")String userId,@PathVariable("block")Integer block){
        userService.block(userId,block);
        if (block==1){
            return RespJson.pack(200,"冻结成功",userService.findAll());
        }else if (block==0){
            return RespJson.pack(200,"解冻成功",userService.findAll());
        }else {
            return RespJson.pack(100,"传值有误",userService.findAll());
        }
    }
}
